import java.util.Scanner;

/**
 * 现有一个图形系统用来求各种图形的面积和周长，为了具备高扩展性以适应未来加入新图形的需要，
 * 图形系统已经制定好了求 面积及周长 的接口规范以及 客户端求面积及周长 的方式。
 *
 */
abstract class Shape {
    // 求面积
    public abstract double getArea();
    // 求周长
    public abstract double getPerimeter();

    // 偏移值--在面积和周长真实值基础上加上偏移值进行安全处理
    protected double offset;
    public void setOffset(double offset) {
        this.offset = offset;
    }
    public double getOffset() {
        return offset;
    }
}

class ShapeOperation {
    public static double getAreaOperation(Shape shape) {
        return shape.getArea();
    }
    public static double getPerimeterOperation(Shape shape) {
        return shape.getPerimeter();
    }
}

// 三角形类
class Triangle extends Shape {
    private final double area;
    private final double perimeter;
    // 求三角形的面积和周长  S=√p(p-a)(p-b)(p-c); p = (a + b + c) / 2
    public Triangle(double a, double b, double c) {
        double p = (a + b + c) / 2;
        this.area = Math.sqrt(p * (p-a) * (p-b) * (p-c));
        this.perimeter = a + b + c;
    }
    @Override
    public double getArea() {
        return this.area;
    }
    @Override
    public double getPerimeter() {
        return this.perimeter;
    }
}

// 格式化输出类.
class FormatOutput {
    private String shapeType;
    private double area;
    private double perimeter;
    public FormatOutput(String shape,double area, double perimeter ) {
        this.area = area;
        this.perimeter = perimeter;
        this.shapeType = shape;
    }
    public String getOutputValue() {
        return this.shapeType + "面积为:" + String.format("%.02f",this.area) +
                ",周长为:" +  String.format("%.02f",this.perimeter) + "\n";
    }

    public void setShapeType(String shape) {
        this.shapeType = shape;
    }

    public void setArea(double area) {
        this.area = area;
    }
    public void setPerimeter(double perimeter) {
        this.perimeter = perimeter;
    }

}

// 长方形
class Rectangle extends Shape{
    private final double area;
    private final double perimeter;
    // 求面积和周长
    public Rectangle(double length, double width) {
        this.area = length * width;
        this.perimeter = 2 * (length + width);
    }
    @Override
    public double getArea() {
        return this.area;
    }
    @Override
    public double getPerimeter() {
        return this.perimeter;
    }
}

public class Test1 {
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);

        double a, b , c; // a,b,c用于存储三角形的三条边
        // 获取三角形的三条边
        a = reader.nextDouble();
        b = reader.nextDouble();
        c = reader.nextDouble();

        // 获取长方形的长和宽
        // length,width用于存储长方形的长和宽
        double length, width;
        length = reader.nextDouble();
        width = reader.nextDouble();

        // area,perimeter用于存储面积和周长
        double area, perimeter;

        // 求三角形的面积和周长
        Shape shape = new Triangle(a, b, c);
        area = ShapeOperation.getAreaOperation(shape);
        perimeter = ShapeOperation.getPerimeterOperation(shape);
        // 格式化输出，保留小数点后2位数据
        FormatOutput formatOutput = new FormatOutput("三角形", area, perimeter);
        System.out.print(formatOutput.getOutputValue());

        // 求长方形的面积和周长
        shape = new Rectangle(length, width);
        area = ShapeOperation.getAreaOperation(shape);
        perimeter = ShapeOperation.getPerimeterOperation(shape);

        formatOutput.setShapeType("长方形");
        formatOutput.setArea(area);
        formatOutput.setPerimeter(perimeter);

        System.out.print(formatOutput.getOutputValue());

    }

}
